<admintpl file="header" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/jquery.jqtimeline.css" /> 
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a href="{:U('Log/index')}">日志列表</a></li>
            <li><a href="{:U('Log/add')}">新增日志</a></li>
        </ul>
        <form class="well form-search  form-inline" method="post" action="{:U('Log/index')}">
            <div class="form-group">
                <label class="sr-only">日志所属月份</label>
                <input type="text" name="work_date" class="input-xt input-deptname form-control WdatePicker" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM'})" value="{:I('request.work_date/s','"%date%"')}" placeholder="选择时间搜索..." style="width:200px;"/>
            </div>
            <button class="btn btn-primary" type="submit" onClick="return checkForm();">搜索</button>
            <a class="btn btn-danger" href="{:U('Log/index')}">清空</a>
        </form>
		<div class="longDemo demo">
			<div id="longTimeLine"></div>
		</div>
        <p>
            <table class="table table-hover table-bordered">
                <thead>
                    <tr>
						  <th>编号</th>
                        <th>创建日期</th>
                        <th>单位部门</th>
                        <th>创建人</th>
                        <th>主题</th>
                        <th>类型</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                <volist name="results" id="vo">
						<tr>
							<td width="120">{$vo.id}</td>
							<td width="120">{$vo.addtime|date='Y-m-d',###}</td>
							<td width="220">{$vo.partment}</td>
							<td width="120">{$vo.username}</td>
							<td>{$vo.title}</td>
							<td width="120">{$vo.type}</td>
							<td width="120">
                            <a href="{:U('Log/view',array('id'=>$vo['id']))}">详情</a>
							<if condition="session('ADMIN_ID') eq $vo['uid'] ">
								| <a href="{:U('Log/edit',array('id'=>$vo['id']))}">编辑</a>
							</if>
							<if condition="session('ADMIN_ID') eq $vo['uid'] or $role_id eq 0">
								| <a href="{:U('Log/delete',array('id'=>$vo['id']))}">删除</a>
							</if>
							</td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </p>
        <div class="pagination">{$page}</div>
    </div>
    <script src="__PUBLIC__/js/common.js"></script>
    <script language="javascript" type="text/javascript" src="__PUBLIC__/js/My97DatePicker/WdatePicker.js"></script>
    <script>
	$(function() {
		var daysNum = "{$daysNum}";
		var year = "{$year}";
		var month = "{$month}";
		var eventDays = "{$eventDays}";
		var totalWidth = $('#longTimeLine').width();
		var nodes = '';
		var events = '';
		var borderWidth = parseInt(daysNum/2)*3;
		if(daysNum%2)
			borderWidth = parseInt(daysNum/2)*3 + 2;
		var gap = parseInt((totalWidth-borderWidth)/(daysNum-1));
		var spaceWidth = (totalWidth-borderWidth) - gap*(daysNum-1);
		var leftSpace = spaceWidth/2;
		for(i=0; i<daysNum; i++){
			var left = (gap-1)*i+leftSpace+(i-1)*3;
			var node_item = '<div class="horizontal-line month-line even-month" style="left:'+ left +'px"> <div class="month">'+(i+1)+'日</div></div>';
			if(i%2){
				left = (gap-1)*i+leftSpace+(i-1)*3+2;
				node_item = '<div class="horizontal-line month-line odd-month" style="left:'+ left +'px"> <div class="month">'+(i+1)+'日</div></div>';
			}
			if(i == 0)
				node_item = '<div class="horizontal-line leftend" style="left:'+ leftSpace +'px"> <div class="year">'+ month +'月</div><div class="month">1日</div></div>';
			if(i == daysNum-1){
				var leftend = totalWidth-leftSpace-2;
				if(daysNum%2)
					leftend -= 1;
				node_item = '<div class="horizontal-line leftend" style="left:'+ leftend +'px"> <div class="year">'+ month +'月</div><div class="month">'+(i+1)+'日</div></div>';
			}
				
			nodes += node_item;
			if(eventDays.indexOf('|'+(i+1)+'|') >= 0)
				events += '<div class="event" id="event_'+ (i+1) +'" data-day="'+ (i+1) +'" style="left:'+ (left-7) +'px">&nbsp;</div>';
		}
		nodes += events;
		var html = '<div class="gt-timeline" style="width:'+ totalWidth +'px"> <div class="main_line" style="width:'+ (totalWidth-spaceWidth) +'px; left:'+ leftSpace +'px"></div>'+ nodes +'</div>';
		$("#longTimeLine").html(html);
		
		var url = "{:U('Log/index')}";
		$("#longTimeLine").on('click','.event',function(){
			var day = $(this).attr('data-day');
			location.href = url + '&time=' + year + '-' + month + '-' + day;
		});
	});
	
	function checkForm(){
		if($('input[name="work_date"]').val())
			return true;
		$('input[name="work_date"]').focus();
		return false;
	}
	
	
	</script>
</body>
</html>